/**
 * MP Software.
 */
package models;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import play.db.jpa.Model;

/**
 * @author Jeremiah John M. Macariola
 *
 */
@Entity
public class Payroll extends Model {

    @ManyToOne
    public Employee employee;

    @ManyToOne
    public PayrollPeriod payrollPeriod;

    public Payroll(Employee employee, PayrollPeriod payrollPeriod) {
        this.employee = employee;
        this.payrollPeriod = payrollPeriod;
    }

    @Override
    public int hashCode() {
        return employee.id.intValue() * payrollPeriod.id.intValue();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Payroll) {
            Payroll other = (Payroll) obj;
            if (employee.id.equals(other.employee.id) && payrollPeriod.id.equals(other.payrollPeriod.id)) {
                return true;
            }
        }

        return false;
    }

}
